Update rule with proper syntax of ReturnArrayClassMethodToYieldRector#2277
Update rule with proper syntax of ReturnArrayClassMethodToYieldRector#2277TomasVotruba merged 1 commit intorectorphp:masterfrom
Conversation
|
Also I was thinking : what about supporting methods referenced by the Example of a failing test case <?php
namespace Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Fixture;
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase;
class DataProviderViaAnnotationOnly extends ParentTestCase
{
/**
* @dataProvider someMethod
*/
public function testSomething($arg1, $arg2, $arg3): void
{
}
public function someMethod(): array
{
return [['some', 'test', 'arguments']];
}
}
?>
-----
<?php
namespace Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Fixture;
use Rector\CodingStyle\Tests\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector\Source\ParentTestCase;
class DataProviderViaAnnotationOnly extends ParentTestCase
{
/**
* @dataProvider someMethod
*/
public function testSomething($arg1, $arg2, $arg3): void
{
}
public function someMethod(): \Iterator
{
yield ['some', 'test', 'arguments'];
}
}
?>Which would probably mean relying on a |
|
Well, this rule is generic and configurable to any class/pattern, not just data providers (it's just an example). If you want to add such a rule for data providers, you can re-use this in a new rule, that would collect all method names from |
rectorphp/rector-src@30f2f91 [CodeQuality][DeadCode] Handle SimplifyUselessVariableRector+RemoveOverriddenValuesRector (#2277)
No description provided.